package tests;

import javax.vecmath.Point3d;
import primitive3D.Quadrilateral;
import rayTracer.Ray;

public class TestQuadrilateral {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Point3d a = new Point3d(1,0,1);
		Point3d b = new Point3d(1,1,0);
		Point3d c = new Point3d(0,1,0);
		Point3d d = new Point3d(0,0,1);
		Quadrilateral q = new Quadrilateral(a,b,c,d, null);
		System.out.println(q);

		System.out.println("Los puntos del cuadrilatero son: ");
		Point3d[] puntos = q.getPoints();
		for( int i=0; i < 4; i++ ) {
			System.out.print(puntos[i] + " ");	
		}
		System.out.println();
		
		double area = q.area();
		System.out.println("Area del cuadrilatero: " + area);
		
		// Test de interseccion
		Point3d origin = new Point3d(0,0,1);
		Point3d dir = new Point3d(0,0,0);
		Ray r = new Ray(origin,dir);
		System.out.println(r);
		
		Point3d[] pts = new Point3d[2];
		pts[0] = new Point3d();
		pts[1] = new Point3d();
		double dist=0;
		if( (dist=q.intersects(r)) > 0 ) {
			System.out.print("Punto de interseccion, distancia= "+dist);
			
		}
	}

}
